#include"mqueue.h"
#include"stdio.h"
#include"string.h"
int main()
{
    struct mq_attr attr ;
    attr.mq_maxmsg=10;
    attr.mq_msgsize=128;
    
    mqd_t mq=mq_open("/mq_test",O_RDWR|O_CREAT,0644,attr);

    if(mq==-1)
    {
        perror("mq_open");
        return -1;
    }

    int ret=mq_send(mq,"hello world",strlen("hello world"),1);
    if(ret==-1){
        perror("mq_send");
        return -1;
    }


    char buf[128];
   int  size=mq_receive(mq,buf,128,0);
    if(size==-1){
        perror("mq_receive");
        return -1;
    }
    if(size>0){
        printf("receive:%s\n",buf);
    }
    mq_close(mq);
    mq_unlink("/mq_test");
}